<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org"
      xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<meta charset="utf-8">
<head th:include="include :: header('')"></head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="gotoTask-form">
                <div class="select-list">
                    <ul>
                        <li>
                            流程名称：<input type="text" name="name"/>
                        </li>
                        <li>
                            部署编号：<input type="text" name="deploymentId"/>
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table" data-mobile-responsive="true"></table>
        </div>
    </div>
</div>
<div th:include="include :: footer"></div>
<script th:inline="javascript">
    var applyFlag = [[${@permission.hasPermi('activiti:task:apply')}]];
    var prefix = ctx + "activiti/task";
    $(function () {
        var options = {
            uniqueId: "deploymentId",
            url: prefix + "/gotoList",
            modalName: "申请任务",
            search: false,
            showExport: false,
            columns: [{
                checkbox: true
            },
                {
                    field: 'processId',
                    title: '流程编号'
                },
                {
                    field: 'deploymentId',
                    title: '部署编号'
                },
                {
                    field: 'name',
                    title: '流程名称'
                },
                {
                    field: 'key',
                    title: '流程KEY'
                },
                {
                    field: 'category',
                    title: '流程类别'
                },
                {
                    field: 'version',
                    title: '流程版本'
                },
                {
                    title: '流程文件名称',
                    formatter: function (value, row, index) {
                        var url = ctx + 'activiti/process/resource/' + row.resourceName + '/' + row.deploymentId;
                        var action = '<a href="' + url + '" target="_blank">' + row.resourceName + '</a>';
                        return action;
                    }
                },
                {
                    title: '流程图片名称',
                    formatter: function (value, row, index) {
                        var url = ctx + 'activiti/process/resource/' + row.diagramResourceName + '/' + row.deploymentId;
                        var action = '<a href="' + url + '" target="_blank">' + row.diagramResourceName + '</a>';
                        return action;
                    }
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function (value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + applyFlag + '" href="#" title="发起任务" onclick="apply(\'' + row.processId + '\')"><i class="fa fa-paper-plane">申请</i></a> ');
                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);
    });

    /**
     * 发起任务
     * @param processId
     */
    function apply(processId) {
        var url = prefix +'/form/'+ processId ;
        $.modal.openFull("薪资档级申请", url);
    }
</script>
</body>
</html>